package licode.unisop.platform.client.authinfo;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class AuPlatformProp {
    /**
     * 当前同步的最新平台权限数据，如果此值和对应平台的不一致，则
     * 需要同步数据
     */
    private int plVersion;
    private String userType;

    private AuProperties plProp = new AuProperties();
    private Map<String, AuProperties> clnProps;

    public AuProperties findProp(String clientId) {
        AuProperties auProp = null;
        if (null != clnProps) {
            auProp = clnProps.get(clientId);
        }
        if (null == auProp) {
            auProp = plProp;
        }
        return auProp;
    }

    public AuProperties getClientProp(String clientId) {
        AuProperties auProp = null;
        if (null != clnProps) {
            auProp = clnProps.get(clientId);
        }
        return auProp;
    }

    public AuPlatformProp clone() {
        AuPlatformProp target = new AuPlatformProp();

        if (null != plProp) {
            target.setPlProp(plProp.clone());
        }

        target.setClnProps(new HashMap<>(clnProps));

        return target;
    }
}
